<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>

<div style="margin:20px 0;"></div>
<div class="easyui-panel" >
    <div style="padding:10px 60px 20px 60px">
        <form id="serviceForm"  name="serviceForm" method="post" >
            <input id="service_uuid" type="hidden" name="service_uuid" value="${serviceInfEntity.service_uuid}"/>
            <input id="rec_id" type="hidden" name="rec_id" value="${serviceInfEntity.rec_id}"/>
            <table cellpadding="5" style="width:100%">
                <tr>
                    <td>业务编号:</td>
                    <td><input class="easyui-textbox" <c:if test="${serviceInfEntity.service_uuid != '' && serviceInfEntity.service_uuid != null}">readonly="readonly"</c:if> type="text" name="service_no" data-options="required:true,validType:['checkServiceNo']" value="${serviceInfEntity.service_no }"></input></td>
                </tr>
                <tr>
                    <td>业务名称:</td>
                    <td><input class="easyui-textbox" type="text"  name="service_name" data-options="required:true,validType:['length[0,30]']" value="${serviceInfEntity.service_name}"></input></td>
                </tr>
                <tr>
                    <td>业务状态:</td>
                    <td><code:codeSelect id="service_st" name="service_st" code_type="service_st" showSelect="true" selectId="${serviceInfEntity.service_st}"></code:codeSelect></td>
                </tr>
                <tr>
                    <td>业务类型:</td>
                    <td><code:codeSelect id="service_type" name="service_type" code_type="service_type" showSelect="true" selectId="${serviceInfEntity.service_type}"></code:codeSelect></td>
                </tr>
                <tr>
                    <td>营业开始日期:</td>
                    <td><input id="begdate" type="text" name="begdate" class="easyui-datebox" value="${serviceInfEntity.begdate}"></td>
                </tr>
                <tr>
                    <td>每天营业开始时间:</td>
                    <td><input id="begtime" name="begtime" class="easyui-timespinner" style="width:80px;" data-options="min:'00:00:00',max:'23:59:59',showSeconds:true" value="${serviceInfEntity.begtime}"></td>
                </tr>
                <tr>
                    <td>营业结束日期:</td>
                    <td><input id="enddate" type="text" name="enddate" class="easyui-datebox" value="${serviceInfEntity.enddate}"></td>
                </tr>
                <tr>
                    <td>每天营业结束时间:</td>
                    <td><input id="endtime" name="endtime" class="easyui-timespinner" style="width:80px;" data-options="min:'00:00:00',max:'23:59:59',showSeconds:true" value="${serviceInfEntity.endtime}"></td>
                </tr>

            </table>

            <div style="text-align:center;padding:5px">
                <%--<a href="javascript:void(0)" class="easyui-linkbutton btn detail-remove" onclick="saveService()">保存</a>--%>
                <%--<a href="javascript:void(0)" class="easyui-linkbutton btn" onclick="back()">返回</a>--%>

                <jiepos:buttonDetailTag menuCode="${menuCode}" formId="serviceForm"></jiepos:buttonDetailTag>
            </div>
        </form>
    </div>
</div>
<script>

    function saveService(urls) {
        if($("#service_st").val() == "" || $("#service_type").val() == ""){
            $.jpmessage.info('请选择业务状态和业务类型');
            return;
        }
        if($("#begdate").val() != null && $("#begdate").val() != "" && $("#enddate").val()!=null && $("#enddate").val()!="" && $("#begdate").val() > $("#enddate").val()){
            $.jpmessage.info('开始日期应早于结束日期');
            return;
        }
        if($("#begtime").val() != null && $("#begtime").val() != "" && $("#endtime").val()!=null && $("#endtime").val()!="" && $("#begtime").val() > $("#endtime").val()){
            $.jpmessage.info('开始时间应早于结束时间');
            return;
        }
        if($("#serviceForm").form("validate")){
            var options ={
                url:'<c:url value="/serviceInf/checkService.do"/>',
                type:'post',
                success:function(data){
                    var result=data;
                    if("success"==result){
                        //表单提交的方法、比如ajax提交
                        $("#serviceForm").attr("action",urls);
                        document.getElementById("serviceForm").submit();
                    }else{
                        $.jpmessage.info('业务编号业务名称不能重复!');
                    }
                }
            };
            $("#serviceForm").ajaxSubmit(options);
        }
    }

    $(document).ready(function() {
        $.extend($.fn.textbox.defaults.rules, {
            checkServiceNo: {
                validator: function(value){
                    var reg = new RegExp("^[a-zA-Z0-9_]{0,20}$");
                    return reg.test(value);
                },
                message: '业务编号需为0-20位数字或字母'
            }
        });

    });

</script>